import { ApiProperty } from '@nestjs/swagger';
import { IsOptional, IsNumber, IsDateString } from 'class-validator';

export class BaseDto {
  @ApiProperty({ description: '主键ID', required: false })
  @IsOptional()
  @IsNumber()
  id?: number;

  @ApiProperty({ description: '创建时间', required: false })
  @IsOptional()
  @IsDateString()
  createdAt?: string;

  @ApiProperty({ description: '更新时间', required: false })
  @IsOptional()
  @IsDateString()
  updatedAt?: string;
}

export class PaginationDto {
  @ApiProperty({ description: '页码', default: 1 })
  @IsOptional()
  @IsNumber()
  page?: number = 1;

  @ApiProperty({ description: '每页数量', default: 10 })
  @IsOptional()
  @IsNumber()
  limit?: number = 10;
}

export class PaginationResponseDto<T> {
  @ApiProperty({ description: '数据列表' })
  data: T[];

  @ApiProperty({ description: '总数' })
  total: number;

  @ApiProperty({ description: '页码' })
  page: number;

  @ApiProperty({ description: '每页数量' })
  limit: number;

  @ApiProperty({ description: '总页数' })
  totalPages: number;
}

